package club.janna.rpcdemo.client;

import club.janna.rpcdemo.api.UserService;
import club.janna.rpcdemo.domain.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;
import java.util.List;

@SpringBootApplication(scanBasePackages = {"club.janna.rpcdemo.client", "club.janna.rpcdemo.codec"})
public class ClientBootstrap {
    public static void main(String[] args) throws IOException {
        ConfigurableApplicationContext context = new SpringApplication(ClientBootstrap.class).run(args);
        RPCProxyFactory factory = context.getBean(RPCProxyFactory.class);
        UserService userService = factory.getBean(UserService.class);

        // 测试接口
        String result = userService.sayHello("janna");
        System.out.println(result);

        User user = userService.getById(1L);
        System.out.println(user);

        List<User> list = userService.list();
        System.out.println(list);

        context.close();
    }
}
